package com.huilian.iotbox.data.enums;

import lombok.Getter;

import java.util.stream.Stream;

@Getter
public enum DeviceTypeEnum {
    CRANE_MACHINE(1, "娃娃机"),
    GASHAPON_MACHINE(2, "扭蛋机"),
    CONVERTIBLE_CURRENCY_MACHINE(3, "兑币机"),
    CARD_MACHINE(4, "卡片机"),
    WA_TANG_MACHINE(11, "挖糖机"),
    SHOUT_MACHINE(12, "喊泉"),
    SCOOTER_MACHINE(13, "滑板车"),
    RAILS_MACHINE(14, "滑轨车"),
    SUPER_MONEY_CHANGER(16, "超级兑币机"),
    BATTERY_CAR_CHARGING_PILE(17, "电瓶车共享充电桩"),
    HAO_JI_LE_PERAMBULATOR(18, "儿童车"),
    MARSHMALLOW(19, "棉花糖"),
    ARCADE_GAME(20, "共享街机"),
    CURRENCY_TYPE(21, "通用类型"),
    SINGING_MACHINE(22, "唱歌机"),
    VENDING_MACHINE(23, "无屏售货机"),
    SCREEN_VENDING_MACHINE(24, "有屏售货机"),
    OPEN_DOOR_VENDING_MACHINE(25, "开门式售货机"),
    LOTTERY_MACHINE(26, "彩票游戏机"),
    CASH_REGISTER(27,"存币机"),
    TICKET_DEPOSITING_MACHINE(28,"存票机"),
    GATE_GATE(29,"门闸"),
    COUCH_FOR_MASSAGE(30,"按摩垫"),
    BLEND_VENDING_MACHINE(31,"混合售货机"),
    ONE_TO_MANY_BOXES(32,"一拖多盒子"),
    PHOTOGRAPH_MACHINE(33,"拍照机"),
    PUDDLE_JUMPER(34,"小火车"),

    ;

    private Integer code;
    private String desc;

    DeviceTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static DeviceTypeEnum getDeviceTypeId(Integer value) {
        return Stream.of(DeviceTypeEnum.values())
                .filter(p -> p.code.equals(value))
                .findAny()
                .orElse(null);
    }


    public static String getDesc(Integer code) {
        for (DeviceTypeEnum value : DeviceTypeEnum.values()) {
            if (value.getCode().equals(code)){
                return value.getDesc();
            }
        }
        return "未知设备类型，设备码：" + code;
    }
}
